﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Pampa.Grid.Core.Filters;

namespace Pampa.MVC.Fluent.Grid
{
    public class FilterStringBuilder<T> : FilterBuilder<T, string>
    {
        private readonly CustomGridBuilder<T> _gridBuilder;

        public FilterStringBuilder(CustomGridBuilder<T> gridBuilder, GroupFilter rootFilter, Expression<Func<T, string>> property) : base(rootFilter, property)
        {
            _gridBuilder = gridBuilder;
        }

        public FilterModifierBuilder<T> IsNull()
        {
            AddFilter(OperationType.IsNull, null);
            return new FilterModifierBuilder<T>(_gridBuilder, this);
        }

        public FilterModifierBuilder<T> IsNotNull()
        {
            AddFilter(OperationType.IsNotNull, null);
            return new FilterModifierBuilder<T>(_gridBuilder, this);
        }

        public FilterModifierBuilder<T> EqualTo(string value)
        {
            AddFilter(OperationType.Equal, value);
            return new FilterModifierBuilder<T>(_gridBuilder, this);
        }

        public FilterModifierBuilder<T> NotEqualTo(string value)
        {
            AddFilter(OperationType.NotEqual, value);
            return new FilterModifierBuilder<T>(_gridBuilder, this);
        }

        public FilterModifierBuilder<T> Contains(string value)
        {
            AddFilter(OperationType.Contains, value);
            return new FilterModifierBuilder<T>(_gridBuilder, this);
        }

        public FilterModifierBuilder<T> EndsWith(string value)
        {
            AddFilter(OperationType.EndsWith, value);
            return new FilterModifierBuilder<T>(_gridBuilder, this);
        }

        public FilterModifierBuilder<T> StartsWith(string value)
        {
            AddFilter(OperationType.StartsWith, value);
            return new FilterModifierBuilder<T>(_gridBuilder, this);
        }
    }
}
